import React, { useState } from "react";
import { CalendarPicker, NavBar } from "antd-mobile";
import dayjs from 'dayjs'
import { useNavigate } from "react-router-dom";
import {useDispatch} from 'react-redux'
import { setDate } from "../../store/citylist/Citylist";
function Rq() {
  const [visible4, setVisible4] = useState(true);
  const navigate = useNavigate()
  const dispatch = useDispatch()

//   当前日期
  const sj = new Date().getDate()
  console.log(sj)
  const min = new Date();

//   最小当前日期
  min.setDate(sj);
//   min.setMonth(min.getMonth() - 1);

  const max = new Date();
//   最大 —— 当前日期加十五天
  max.setDate(sj+15);
//   max.setMonth(max.getMonth() + 1);
  return (
    <div>
        <NavBar>日期页面</NavBar>
      <CalendarPicker
        min={min}
        max={max}
        //   defaultValue={now}
        //   selectionMode='single'
        visible={visible4}
        onConfirm={(val) => {
            // console.log(val)
            const timer = dayjs(val).format('YYYY-MM-DD')
            console.log(timer)
            dispatch(setDate(timer))
            navigate(-1)
        }}
        //   onMaskClick={() => setVisible4(false)}
      />
    </div>
  );
}

export default Rq;
